package com.dex4d.ui.wallet.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.dex4d.R;
import com.dex4d.core.AppBaseActivity;
import com.dex4d.event.ExitEvent;
import com.dex4d.utils.Commons;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by chengyuchun on 2018/10/17.
 *
 */
public class PreLoginActivity extends AppBaseActivity {


    @BindView(R.id.btn_restore)
    Button mBtnRestore;

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, PreLoginActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public int getLayoutId() {
        return R.layout.wallet_pre_login;
    }

    @Override
    public void initVariables() {
        EventBus.getDefault().register(this);
    }

    @Override
    public void loadData() {

    }

    @OnClick({R.id.btn_restore,R.id.btn_sign_up})
    public void onViewClicked(View view) {
        Bundle bundle =  new Bundle();
        switch (view.getId()) {
            case R.id.btn_restore:
                bundle.putString(Commons.BUNDLE_KEYS.TO_TARGET,Commons.BUNDLE_KEYS.TO_RESTORE);
                openActivity(PinActivity.class,bundle);
                break;
            case R.id.btn_sign_up:
                bundle.putString(Commons.BUNDLE_KEYS.TO_TARGET,Commons.BUNDLE_KEYS.TO_SIGN_UP);
                openActivity(PinActivity.class,bundle);
                break;
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(ExitEvent event) {
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
